{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "2c62f1ae",
   "metadata": {},
   "outputs": [],
   "source": [
    "import cv2\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import os\n",
    "IMG_PATH = r\"D:\\Pic_data\"\n",
    "\n",
    "def read_pic(img_path):\n",
    "    f_list = np.array([])\n",
    "    pic_tags = np.array([])\n",
    "    \n",
    "    for f in os.listdir(img_path):\n",
    "        img = cv2.imread(os.path.join(IMG_PATH, f))\n",
    "        # 跳过损坏的图片\n",
    "        if img is None:\n",
    "            continue\n",
    "        f_list = np.append(f_list, f)\n",
    "        \n",
    "        # 如果图片名称中含Normal,说明是正常道路\n",
    "        if(f.find('normal') != -1):\n",
    "            pic_tags = np.append(pic_tags, 1)\n",
    "        else:\n",
    "             pic_tags = np.append(pic_tags, 0)\n",
    "    return [f_list, pic_tags]\n",
    "\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
